import * as types from './mutation_types'
import request from '../../../util/axios'
// import nav from '../../../../public/js/nav.json'

// 获取左侧导航栏
export const getNav = ({ commit }) => {
  // commit(types.NAV_SET_RETRIEVED, nav.navList)
  commit(types.NAV_SET_RETRIEVED, null)
  commit(types.NAV_SET_LOADING, true)
  /* fetch('./js/nav.json?_=' + (new Date())).then((res) => {
    return res.json()
  }).then((data) => {
    commit(types.NAV_SET_RETRIEVED, data.navList)
  }).catch(() => {
    commit(types.NAV_SET_RETRIEVED, null)
  }) */

  request({
    url: '/yuyi-user-boot/api/sys/sysMenu/routes'
  }).then((res) => {
    commit(types.NAV_SET_RETRIEVED, res.data.data)
    commit(types.NAV_SET_LOADING, false)
  }).catch(() => {
    commit(types.NAV_SET_RETRIEVED, null)
    commit(types.NAV_SET_LOADING, false)
  })
}
